package p3as.cliente;

import java.awt.Graphics;

public class Boundary implements Drawable {
    private int width;
    private int heigth;
    
    public Boundary(int width, int heigth){
        this.width = width;
        this.heigth = heigth;
    }
    
    @Override
    public void addChild(Drawable drawable) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void removeChild(Drawable drawable) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public Drawable getChild(int index) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public int collision(Drawable drawable) {
        Ball ball = (Ball) drawable;
        if(drawable.getX() <= 0)    ball.setDx(ball.getDx()*-1);
        if(drawable.getY() <= 0)    ball.setDy(ball.getDy()*-1);
        if(drawable.getX()+drawable.getWidth() >= width)    ball.setDx(ball.getDx()*-1);
        if(drawable.getY()+drawable.getHeigth() >= heigth)   ball.setDy(ball.getDy()*-1);
        return 0;
    }

    @Override
    public void render(Graphics graphics) {
        graphics.drawRect(0, 0, width, heigth);
    }

    @Override
    public int getX() {
        return 0;
    }

    @Override
    public int getY() {
        return 0;
    }

    @Override
    public int getWidth() {
        return width;
    }

    @Override
    public int getHeigth() {
        return heigth;
    }

    @Override
    public void setScore(Score score) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
